package com.lzh.chatnote.user.dao;

import com.lzh.chatnote.user.domain.entity.Role;
import com.lzh.chatnote.user.mapper.RoleMapper;
import com.lzh.chatnote.user.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author lzh
 * @since 2025-06-06
 */
@Service
public class RoleDao extends ServiceImpl<RoleMapper, Role> implements RoleService {

    public List<String> queryRole(List<Long> roleList) {
        return Optional.ofNullable(lambdaQuery().in(Role::getId, roleList).list())
                .orElse(Collections.emptyList()).stream()
                .map(Role::getCode).collect(Collectors.toList());
    }
}
